package cn.cdeden.knowledge.enums;

import cn.cdeden.knowledge.domain.dto.EnterpriseConfigDto;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * TODO
 *
 * @author username
 * @date 2024/8/6 9:36
 * @describe:
 **/

@AllArgsConstructor
@Getter
public enum EnterpriseConfigEnums {
    ENTERPRISE_UPLOAD_PROCESS_CONFIG("ENTERPRISE_UPLOAD_PROCESS_CONFIG","上传流程配置","perm","value值含义：process:流程，perm:权限"),
    ENTERPRISE_UPLOAD_FILE_CONFIG("ENTERPRISE_UPLOAD_FILE_CONFIG","上传相同名称文件处理配置","copy","value值含义：version:文件版本，copy:文件复制"),

    TEAM_TO_ENTERPRISE_CONFIG("TEAM_TO_ENTERPRISE_CONFIG","团队到企业库配置","normal","value值含义：process:流程，normal:普通"),

    PERSONAL_ENTERPRISE_CONFIG("PERSONAL_ENTERPRISE_CONFIG","个人到企业库配置","normal","value值含义：process:流程，normal:普通");

    private final String configCode;
    private final String configName;
    private final String configDefaultValue;
    private final String configDescription;

    public static EnterpriseConfigEnums find(String configCode)
    {
        for (EnterpriseConfigEnums enums : EnterpriseConfigEnums.values()) {
            if (enums.getConfigCode().equals(configCode)) {
                return enums;
            }
        }
        return null;
    }

    public static EnterpriseConfigDto getEnterpriseConfigDto(String configCode){
        EnterpriseConfigEnums enterpriseConfigEnums = find(configCode);
        if (enterpriseConfigEnums!=null){
            EnterpriseConfigDto enterpriseConfigDto = new EnterpriseConfigDto();
            enterpriseConfigDto.setCode(enterpriseConfigEnums.getConfigCode());
            enterpriseConfigDto.setName(enterpriseConfigEnums.getConfigName());
            enterpriseConfigDto.setValue(enterpriseConfigEnums.getConfigDefaultValue());
            enterpriseConfigDto.setDescription(enterpriseConfigEnums.getConfigDescription());
            return enterpriseConfigDto;
        }else return null;
    }
}
